package 双指针;

/**
 * @author zhengTao
 * @version 1.0
 * @description: 删除有序数组中的重复项
 * @date 2022/10/14 14:34
 */
public class Demo26 {
    public int removeDuplicates(int[] nums) {
        if(nums.length<=1){
            return nums.length;
         }
           int slow=1;
          for (int i = 1; i < nums.length; i++) {
                if(nums[i]!=nums[i-1]){
                    nums[slow++]=nums[i];
                }
        }
          return slow;
    }
}
